package JasPerl::JSTL::Fmt::BundleTag;

use 5.010;
use strict;
use warnings;

use parent qw(JasPerl::TagExt::JspBodyTag);

use JasPerl::JSTL::Fmt::LocalizationContext;

sub set_basename {
    $_[0]->{basename} = $_[1];
}

sub set_prefix {
    $_[0]->{prefix} = $_[1];
}

sub get_prefix {
    return $_[0]->{prefix};
}

sub get_bundle {
    return $_[0]->{bundle};
}

sub do_tag {
    my $self = shift;
    my $context = $self->get_jsp_context();
    my $basename = $self->{basename} // ''; # no default bundle
    $self->{bundle} = JasPerl::JSTL::Fmt::LocalizationContext->get_bundle($context, $basename);
    $self->SUPER::do_tag();
}

1;
